import { handleRouter } from "./router/handle-router";
import { rewriteRouter } from "./router/rewrite-router";
import type { IRegisterMicroApp } from "./type";

let _app: IRegisterMicroApp[] = [];

export const getApps = () => _app;

export const registerMicroApps = (apps: IRegisterMicroApp[]) => {
  _app = apps;
};

export const start = () => {
  // 
  /**
   * 微前端运行原理：
   * 1. 监听路由变化
   * 2. 匹配子应用
   * 3. 加载子应用
   * 4. 渲染子应用
   */
  
  // 监听路由变化
  rewriteRouter()

  // 初始执行匹配 -> 处理路由变化
  handleRouter()
};
